<template>
  <div class="config-list">
    <el-radio-group v-model="type">
      <div class="item">
        <el-radio label="TYPE_EVERY" class="choice" :disabled="disabled">每年</el-radio>
      </div>
      <div class="item">
        <el-radio label="TYPE_RANGE" class="choice" :disabled="disabled">区间</el-radio>
        <span class="item-text">从</span>
        <el-input-number v-model="valueRange.start" :disabled="type!==TYPE_RANGE || disabled" :min="0" :precision="0" class="w120" />
        <span class="item-text">年至</span>
        <el-input-number v-model="valueRange.end" :disabled="type!==TYPE_RANGE || disabled" :min="1" :precision="0" class="w120" />
        <span class="item-text">年</span>
      </div>
      <div class="item">
        <el-radio label="TYPE_LOOP" class="choice" :disabled="disabled">循环</el-radio>
        <span class="item-text">从</span>
        <el-input-number v-model="valueLoop.start" :disabled="type!==TYPE_LOOP || disabled" :min="0" :precision="0" class="w120" />
        <span class="item-text">年开始，间隔</span>
        <el-input-number v-model="valueLoop.interval" :disabled="type!==TYPE_LOOP || disabled" :min="1" :precision="0" class="w120" />
        <span class="item-text">年</span>
      </div>
    </el-radio-group>
  </div>
</template>

<script>
import mixin from './mixin'

export default {
  name: 'Year',
  mixins: [mixin],
  data() {
    return {}
  },
  watch: {
    value_c(newVal, oldVal) {
      // console.info('change:' + newVal)
      this.$emit('change', newVal)
    }
  },
  created() {
    const nowYear = (new Date()).getFullYear()
    this.DEFAULT_VALUE = '*'
    this.minValue = 0
    this.maxValue = 0
    this.valueRange.start = nowYear
    this.valueRange.end = nowYear + 100
    this.valueLoop.start = nowYear
    this.valueLoop.interval = 1
    // console.info('created')
    this.parseProp(this.prop)
  }
}
</script>

<style lang="scss" scoped>
  @import "mixin.scss";
</style>
